package com.gitee.aurora.dao.impl;

import com.gitee.aurora.comm.AuroraJdbcTemplate;
import com.gitee.aurora.dao.BaqCheckDao;
import com.gitee.aurora.entity.TabAjAqBaqsyqkdjb;
import com.gitee.aurora.vo.DataCheckVo;
import com.mysql.cj.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * author: jiangfuxiao
 * Date:2022/9/2 11:47
 */
@Repository("baqCheckDaoImpl")
class BaqCheckDaoImpl implements BaqCheckDao {

    @Autowired
    private AuroraJdbcTemplate auroraJdbcTemplate;



    @Override
    public List<TabAjAqBaqsyqkdjb> queryTableData(DataCheckVo vo) {
        List<TabAjAqBaqsyqkdjb> list = new ArrayList<>();
        StringBuilder builder = new StringBuilder(vo.getSql());
        builder.append("  WHERE 1=1 ");
        if (!StringUtils.isNullOrEmpty(vo.getStartTime())){
            builder.append("  AND DT_UPDATE_TIME >=  ").append(vo.getStartTime());
        }
        if (!StringUtils.isNullOrEmpty(vo.getEndTime())){
            builder.append("  AND DT_UPDATE_TIME <=  ").append(vo.getEndTime());
        }
        try {
            list = auroraJdbcTemplate.queryForMapToUpperCaseList(builder.toString(), TabAjAqBaqsyqkdjb.class);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }
}
